package com.library.service;

import org.apache.commons.codec.digest.DigestUtils;

import com.library.dao.StudentDao;

import com.library.entity.Student;


import my.db.Page;

public class StudentService {

	private StudentDao dao = new StudentDao();

	public Student validStudent(String uname, String passwd) {
		Student student = dao.findByName(uname);
		if (student != null) {
			//String pwd = DigestUtils.md5Hex(passwd);
			String pwd=passwd;
			if (student.getPasswd().equals(pwd)) {
				return student;
			}
		}

		return null;
	}
	public Page<Student> list(Page<Student> page, String title) {
		return dao.findPage(page, title);
	}

	public void save(Student student) {
		dao.save(student);
	}

	public Student get(Long id) {
		return dao.get(id);
	}

	public void update(Student student) {
		dao.update(student);
	}

	public void delete(long id) {
		dao.delete(id);		
	}
	public static void main(String[] args) {
		String xx = DigestUtils.md5Hex("123456");
		System.out.println(xx);
	}
}
